//
//  ZHClinicBaseViewController.m
//  Doctor
//
//  Created by liuzhishan on 15/12/16.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHClinicBaseViewController.h"
#import  "ZHZHGetLanguageTool.h"
@interface ZHClinicBaseViewController ()


@end

@implementation ZHClinicBaseViewController

-(void)backMyController
{
    [self.navigationController popViewControllerAnimated:YES];
    
}

-(void)addMyBgImageView
{
    UILabel *myLabelBg=[[UILabel alloc] init];
    [myLabelBg setMyFramewithX:12 andY:100 andWidth:140 andHeight:45];
    myLabelBg.textColor=[UIColor whiteColor];
    myLabelBg.textAlignment = NSTextAlignmentCenter;
    myLabelBg.font=[UIFont systemFontOfSize:25 *WIDPro -2];
    [self.view addSubview:myLabelBg];
    self.lableTitle = myLabelBg;
    
    self.naviTitleLable.text = @"诊所运营";
    self.imageBg.image = [UIImage imageNamed:@"background"];
    
    UIImageView *myImageBg = [[UIImageView alloc]init];
    [myImageBg setMyFramewithX:12 andY:100 andWidth:1005 andHeight:620];
    [self.view addSubview:myImageBg];
    myImageBg.image = [UIImage imageNamed:@"background3"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addMyBgImageView];
    [self addMyBaseChildViews];
    [self addMyBaseNaviBackBtn];
   
    
}

-(void)addMyBaseNaviBackBtn
{
    
    
    UIImageView *imageView = [[UIImageView alloc]init];
    [imageView setMyFramewithX:6 andY:34 andWidth:50 andHeight:20];
      imageView.image = [UIImage imageNamed:@"NaviBack"];
    imageView.userInteractionEnabled = YES;
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backDismiss)];
    
    [imageView addGestureRecognizer:tap];
    
    [self.view addSubview:imageView];
}

-(void)backDismiss
{
    [self.navigationController popViewControllerAnimated:YES];
}



-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    ZHTimeView *timeView = [self.view viewWithTag:100099];
    
    [self addPickerImageView:timeView.firstPicker];
    [self addPickerImageView:timeView.lastPicker];
    
    [timeView bringSubviewToFront:timeView.firstPicker];
    [timeView bringSubviewToFront:timeView.lastPicker];
    
    
    
}

-(void)addPickerImageView:(UIDatePicker*)picker
{
    UIView *view1 = picker.subviews[0].subviews[0].subviews[0].subviews[2];
    
    //nslog(@"%@",view1);
    
    CGRect rect =  CGRectMake(picker.x + view1.x + 15*WIDPro, picker.y + view1.y, view1.width - 30*WIDPro, view1.height);
    
    UIImageView *imageBg = [[UIImageView alloc]init];
    imageBg.image = [UIImage imageNamed:@"pickertimeBg"];
    imageBg.frame = rect;
 
    
    [self.timePickerView addSubview:imageBg];
    

    
    
    
//    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, view1.width, view1.height)];
//    
//    imageView.layer.masksToBounds = YES;
//    //设置圆角度
//    imageView.layer.cornerRadius = imageView.width / 20.0;
//    
//    
//    
//    
//
//    imageView.image = [UIImage imageNamed:@"dateImage"];
//    //[view1 addSubview:imageView];
//    
//    
//    
//    for ( int i = 0;  i < view1.subviews.count - 1; i ++) {
//        
//        UIView *subview = view1.subviews[i];
//        
//        [view1 bringSubviewToFront:subview];
//        
//        
//        
//    }
    
    
    
    
}

-(void)addMyBaseChildViews
{
    ZHTimeView *timePickerView = [[ZHTimeView alloc]init];
    [timePickerView setMyFramewithX:280 andY:150 andWidth:680 andHeight:80];
    timePickerView.tag = 100099;
    [self.view addSubview:timePickerView];
    self.timePickerView = timePickerView;
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
